// RoundRect.cpp: implementation of the CRoundRect class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "8085.h"
#include "RoundRect.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CRoundRect::CRoundRect() : CShape()
{
    Init();
}

CRoundRect::CRoundRect(CRect r) : CShape()
{
    Init();
    SetProperty(r);
}

CRoundRect::~CRoundRect()
{

}

void CRoundRect::SetProperty(CRect r)
{
    m_nProperty = r;
    SetVirtualLength(r.right+5);
}

int CRoundRect::Draw(CDC *pDC,BOOL bErase)
{
    CBrush fill(bErase ? pDC->GetBkColor() : m_FillColour);
    CPen pen(PS_SOLID,1,(bErase ? pDC->GetBkColor() : m_BorderColour));

	CBrush *saveBrush = pDC->SelectObject(&fill);
    CPen *savePen = pDC->SelectObject(&pen);
    CPoint p(6,6);
	pDC->RoundRect(m_nProperty,p);
	//pDC->ExtFloodFill(m_nProperty.left+1,m_nProperty.top+1,
    //        pDC->GetBkColor(),FLOODFILLSURFACE);
    pDC->SelectObject(saveBrush);    // restore the saved brush
    pDC->SelectObject(savePen);
    return GetVirtualLength();
}

CRect & CRoundRect::GetProperty()
{
    return m_nProperty;
}

void CRoundRect::Init()
{
    m_nProperty.SetRect(0,0,GetVirtualLength(),GetVirtualHeight());
    SetBorderColour(RGB(0,0,0));
    SetFillColour(RGB(128,255,255));
}
